#!/bin/bash

# ----------------------------------------------------------------------
# Filename:   75645-killall.sh
# Version:    1.0
# Date:       2013/12/19
# Author:     yuanhui.shi
# Email:      yuanhui.shi@cs2c.com.cn
# Summary:    03系统安全功能-01SELinux-03SELinux重要命令-03SELinux安全上下文标签相关命令-09killall
# Notes:      安全上下文标签 killall
# Copyright:  China Standard Software Co., Ltd.
# History：     
#             Version 1.0, 2013/12/19
#             -   The first one
# ----------------------------------------------------------------------

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

source ../../lib/Echo.sh
source ../../lib/XmlParse.sh
source ./lib/Selib.sh
source ${SFROOT}/lib/NetOps.sh

function CleanData ()
{
  SetService ${SERV} ${SERVICE_STATUS}
  SetSElinux ${SELINUX_STATUS}
  EchoInfo "75645-killall.sh执行完毕"
}

trap "CleanData" EXIT
CheckSElinuxStatus

    # set selinux enforcing
    SELINUX_STATUS=`getenforce | tr A-Z a-z`
    SetSElinux enforcing
    EchoResult "set selinux enforcing"

#[ -z "`StatusDaemon httpd |grep pid`" ] && StartDaemon httpd; STATUS=1 || STATUS=0
    SERV=httpd
    StatusDaemon ${SERV}
    SERVICE_STATUS=$?
    SetService ${SERV} start
    EchoResult "set  ${SERV} start"

    netstat -ntlp | grep ${SERV}
    EchoResult "start ${SERV}"

ps -efZ|grep httpd|grep -v 'grep'
EchoResult "当httpd服务开启后，可以查看到httpd 进程"


killall --context system_u:system_r:httpd_t:s0 || killall --context unconfined_u:system_r:httpd_t:s0
sleep 5

! ps -efZ|grep httpd|grep -v 'grep' | grep -v 'defunct'
EchoResult "当httpd进程被killall命令杀掉后，不能查看到httpd 进程"
